using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.Resources;
using System.Windows.Forms;

using SQLString.Dialogs;
using SQLString.AppResource;
using SQLString.Properties;

namespace SQLString.Classes
{
	public class SQLResource
	{
		#region Class Attributes
		#region Member Fields
		string _szAppTitle = string.Empty;
		string _szAppVersion = string.Empty;
		string _szAssmVersion = string.Empty;
		string _szBUILD = string.Empty;
		string _szRELEASE = string.Empty;
		string _szRELEASEDtl = string.Empty;
		bool _bDBBuild = false;
		string _szDBName = string.Empty;
		string _szMessageCap = string.Empty;
		string _szCoder = string.Empty;
		string _szDescrip = string.Empty;
		string _szCopyright = string.Empty;
		string[] _szDBSchema = new string[] { "","","","","",""};
		string[] _szDBFK = new string[] { "", "", "" ,"" };
		string[] _szDBPK = new string[] { "", "", "", "", "", ""};
		//	domain value arrays
		string[] _szDBSeedLang = new string[] { "", "", "", "", "", "","","" };
		string[] _szDBSeedProj = new string[] { "", "", "", "", "", "", "", "", "", "" };
		string[] _szDBSeedDType = new string[] { "", "", "", ""};
		#endregion

		public static string MessageCap = string.Empty;

			#region Properties
		//seed properties
				public string[] SEEDDataTypes
				{
					get
					{
						return _szDBSeedDType;
					}
					set
					{
						_szDBSeedDType = value;
					}

				}
				public string[] SEEDLangData
				{
					get
					{
						return _szDBSeedLang;
					}
					set
					{
						_szDBSeedLang = value;
					}

				}
				public string[] SEEDProjectTypeData
				{
					get
					{
						return _szDBSeedProj;
					}
					set
					{
						_szDBSeedProj = value;
					}

				}


				public string[] PrimaryKeys
				{
					get
					{
						return _szDBPK;
					}
					set
					{
						_szDBPK = value;
					}

				}
				public string[] ForeignKeys
				{
					get
					{
						return _szDBFK;
					}
					set
					{
						_szDBFK = value;
					}

				}
				public string[] TableSchema
				{
					get
					{
						return _szDBSchema;
					}
					set
					{
						_szDBSchema = value;
					}

				}
				public string Title
				{
					get
					{
						return _szAppTitle.Trim();
					}
					set
					{
						_szAppTitle = value.Trim();
					}
				}

				public string Version
				{
					get
					{
						return _szAppVersion.Trim();
					}
					set
					{
						_szAppVersion = value.Trim();
					}
				}

				public string Assembly
				{
					get
					{
						return _szAssmVersion.Trim();
					}
					set
					{
						_szAssmVersion = value.Trim();
					}
				}

				public string Build
				{
					get
					{
						return _szBUILD.Trim();
					}
					set
					{
						_szBUILD = value.Trim();
					}
				}

				public string Release
				{
					get
					{
						return _szRELEASE.Trim();
					}
					set
					{
						_szRELEASE = value.Trim();
					}
				}
				public string ReleaseDetail
				{
					get
					{
						return _szRELEASEDtl.Trim();
					}
					set
					{
						_szRELEASEDtl = value.Trim();
					}
				}
				public string Database
				{
					get
					{
						return _szDBName.Trim();
					}
					set
					{
						_szDBName = value.Trim();
					}
				}

				public bool IsDatabaseEnabled
				{
					get
					{
						return _bDBBuild;
					}
					set
					{
						_bDBBuild = value;
					}
				}

				public string MessageCaption
				{
					get
					{
						return _szMessageCap.Trim();
					}
					set
					{
						_szMessageCap = value.Trim();
						MessageCap = value.Trim();
					}
				}

				public string Developer
				{
					get
					{
						return _szCoder.Trim();
					}
					set
					{
						_szCoder = value.Trim();
					}
				}

				public string Description
				{
					get
					{
						return _szDescrip.Trim();
					}
					set
					{
						_szDescrip = value.Trim();
					}
				}

				public string Copyright
				{
					get
					{
						return _szCopyright.Trim();
					}
					set
					{
						_szCopyright = value.Trim();
					}
				}


		#endregion



		#endregion


		#region Class Behaviors


				/// <summary>
				/// Loads the application value resources.
				/// </summary>
				/// <returnstrue if load was ok, false if not></returns>
				/// **********************************************************************************************************
				/// *	JBH Software Systems
				/// *	Project:	
				/// *	Copyright (C) 2008- 
				/// *
				/// *	Source Code is Property of 
				/// *	Coder:	jeffrey.hamlin
				/// *	EMAIL:	this.notNULL@gmail.com/this@jeffhamlin.com
				/// *	URL:	www.jeffhamlin.com
				/// *	
				/// *	SYS:EVENTYNE.6/23/2008
				/// *
				/// *********************************************************************************************************
		public bool LoadApplicationValueResources()
		{
			try
			{
				ResourceManager rm = new ResourceManager("SQLString.Properties.SQLStringResource", System.Reflection.Assembly.GetExecutingAssembly());

				if (rm != null)
				{
					this.Assembly = ( rm.GetString("appAssemblyVer").Length > 0 ) ? rm.GetString("appAssemblyVer").Replace("\"", "") : string.Empty;
					this.Build = ( rm.GetString("appBUILD").Length > 0 ) ? rm.GetString("appBUILD").Replace("\"", "") : string.Empty;
					this.Copyright = ( rm.GetString("szCopyRight").Length > 0 ) ? rm.GetString("szCopyRight").Replace("\"", "") : string.Empty;
					this.Database = ( rm.GetString("appDB").Length > 0 ) ? rm.GetString("appDB").Replace("\"", "") : string.Empty;
					this.Description = ( rm.GetString("szDescrip").Length > 0 ) ? rm.GetString("szDescrip").Replace("\"", "") : string.Empty;
					this.Title = ( rm.GetString("appTitle").Length > 0 ) ? rm.GetString("appTitle").Replace("\"", "") : string.Empty;
					this.MessageCaption = ( rm.GetString("appMessageCaption").Length > 0 ) ? rm.GetString("appMessageCaption").Replace("\"", "") : string.Empty;
					this.Release = ( rm.GetString("appRelease").Length > 0 ) ? rm.GetString("appRelease").Replace("\"", "") : string.Empty;
					this.ReleaseDetail = ( rm.GetString("appReleaseDetail").Length > 0 ) ? rm.GetString("appReleaseDetail").Replace("\"", "") : string.Empty;
					this.Version = ( rm.GetString("appVersion").Length > 0 ) ? rm.GetString("appVersion").Replace("\"", "") : string.Empty;
					this.Developer = ( rm.GetString("szDeveloper").Length > 0 ) ? rm.GetString("szDeveloper").Replace("\"", "") : string.Empty;
					return true;
				}

				return false;
			}
			catch (System.Resources.MissingManifestResourceException ex)
			{
				Monitor.sErrMsg(ex.Message);
				return false;
			}
			catch (System.IO.IOException ex)
			{
				Monitor.sErrMsg(ex.Message);
				return false;
			}
			catch (Exception ex)
			{
				Monitor.sErrMsg(ex.Message);
				return false;
			}
		}

		/// <summary>
		/// Loads the DB schema.  These schema are the DDL for table creation.
		/// </summary>
		/// <returns></returns>
		/// **********************************************************************************************************
		/// *	JBH Software Systems
		/// *	Project:	
		/// *	Copyright (C) 2008- 
		/// *
		/// *	Source Code is Property of 
		/// *	Coder:	jeffrey.hamlin
		/// *	EMAIL:	this.notNULL@gmail.com/this@jeffhamlin.com
		/// *	URL:	www.jeffhamlin.com
		/// *	
		/// *	SYS:EVENTYNE.6/23/2008
		/// *
		/// *********************************************************************************************************
		public bool LoadDBSchema()
		{
			try
			{
				ResourceManager rm = new ResourceManager("SQLString.Properties.Schema_TABLES", System.Reflection.Assembly.GetExecutingAssembly());

				if (rm != null)
				{
					//	Loading Table DDL
					this.TableSchema[0] = ( rm.GetString("TB1").Length > 0 ) ? rm.GetString("TB1").Replace("\"", "") : string.Empty;
					this.TableSchema[1] = ( rm.GetString("TB2").Length > 0 ) ? rm.GetString("TB2").Replace("\"", "") : string.Empty;
					this.TableSchema[2] = ( rm.GetString("TB3").Length > 0 ) ? rm.GetString("TB3").Replace("\"", "") : string.Empty;
					this.TableSchema[3] = ( rm.GetString("TB4").Length > 0 ) ? rm.GetString("TB4").Replace("\"", "") : string.Empty;
					this.TableSchema[4] = ( rm.GetString("TB5").Length > 0 ) ? rm.GetString("TB5").Replace("\"", "") : string.Empty;
					this.TableSchema[5] = ( rm.GetString("TB6").Length > 0 ) ? rm.GetString("TB6").Replace("\"", "") : string.Empty;
					//	Loading Primary Key DDL
					this.PrimaryKeys[0] = ( rm.GetString("PK1").Length > 0 ) ? rm.GetString("PK1").Replace("\"", "") : string.Empty;
					this.PrimaryKeys[1] = ( rm.GetString("PK2").Length > 0 ) ? rm.GetString("PK2").Replace("\"", "") : string.Empty;
					this.PrimaryKeys[2] = ( rm.GetString("PK3").Length > 0 ) ? rm.GetString("PK3").Replace("\"", "") : string.Empty;
					this.PrimaryKeys[3] = ( rm.GetString("PK4").Length > 0 ) ? rm.GetString("PK4").Replace("\"", "") : string.Empty;
					this.PrimaryKeys[4] = ( rm.GetString("PK5").Length > 0 ) ? rm.GetString("PK5").Replace("\"", "") : string.Empty;
					this.PrimaryKeys[5] = ( rm.GetString("PK6").Length > 0 ) ? rm.GetString("PK6").Replace("\"", "") : string.Empty;
					//	Loading Foreign Key DDL
					this.ForeignKeys[0] = ( rm.GetString("FK1").Length > 0 ) ? rm.GetString("FK1").Replace("\"", "") : string.Empty;
					this.ForeignKeys[1] = ( rm.GetString("FK2").Length > 0 ) ? rm.GetString("FK2").Replace("\"", "") : string.Empty;
					this.ForeignKeys[2] = ( rm.GetString("FK3").Length > 0 ) ? rm.GetString("FK3").Replace("\"", "") : string.Empty;
					this.ForeignKeys[3] = ( rm.GetString("FK4").Length > 0 ) ? rm.GetString("FK4").Replace("\"", "") : string.Empty;
					/******************************** Load Domain Seeding Data	************************************************/
					this.SEEDLangData[0] = ( rm.GetString("TL1").Length > 0 ) ? rm.GetString("TL1").Replace("\"", "") : string.Empty;
					this.SEEDLangData[1] = ( rm.GetString("TL2").Length > 0 ) ? rm.GetString("TL2").Replace("\"", "") : string.Empty;
					this.SEEDLangData[2] = ( rm.GetString("TL3").Length > 0 ) ? rm.GetString("TL3").Replace("\"", "") : string.Empty;
					this.SEEDLangData[3] = ( rm.GetString("TL4").Length > 0 ) ? rm.GetString("TL4").Replace("\"", "") : string.Empty;
					this.SEEDLangData[4] = ( rm.GetString("TL5").Length > 0 ) ? rm.GetString("TL5").Replace("\"", "") : string.Empty;
					this.SEEDLangData[5] = ( rm.GetString("TL6").Length > 0 ) ? rm.GetString("TL6").Replace("\"", "") : string.Empty;
					this.SEEDLangData[6] = ( rm.GetString("TL7").Length > 0 ) ? rm.GetString("TL7").Replace("\"", "") : string.Empty;
					this.SEEDLangData[7] = ( rm.GetString("TLU").Length > 0 ) ? rm.GetString("TLU").Replace("\"", "") : string.Empty;

					this.SEEDProjectTypeData[0] = ( rm.GetString("PT1").Length > 0 ) ? rm.GetString("PT1").Replace("\"", "") : string.Empty;
					this.SEEDProjectTypeData[1] = ( rm.GetString("PT2").Length > 0 ) ? rm.GetString("PT2").Replace("\"", "") : string.Empty;
					this.SEEDProjectTypeData[2] = ( rm.GetString("PT3").Length > 0 ) ? rm.GetString("PT3").Replace("\"", "") : string.Empty;
					this.SEEDProjectTypeData[3] = ( rm.GetString("PT4").Length > 0 ) ? rm.GetString("PT4").Replace("\"", "") : string.Empty;
					this.SEEDProjectTypeData[4] = ( rm.GetString("PT5").Length > 0 ) ? rm.GetString("PT5").Replace("\"", "") : string.Empty;
					this.SEEDProjectTypeData[5] = ( rm.GetString("PT6").Length > 0 ) ? rm.GetString("PT6").Replace("\"", "") : string.Empty;
					this.SEEDProjectTypeData[6] = ( rm.GetString("PT7").Length > 0 ) ? rm.GetString("PT7").Replace("\"", "") : string.Empty;
					this.SEEDProjectTypeData[7] = ( rm.GetString("PT8").Length > 0 ) ? rm.GetString("PT8").Replace("\"", "") : string.Empty;
					this.SEEDProjectTypeData[8] = ( rm.GetString("PT9").Length > 0 ) ? rm.GetString("PT9").Replace("\"", "") : string.Empty;
					this.SEEDProjectTypeData[9] = ( rm.GetString("PT10").Length > 0 ) ? rm.GetString("PT10").Replace("\"", "") : string.Empty;

					this.SEEDDataTypes[0] = ( rm.GetString("DT1").Length > 0 ) ? rm.GetString("DT1").Replace("\"", "") : string.Empty;
					this.SEEDDataTypes[1] = ( rm.GetString("DT2").Length > 0 ) ? rm.GetString("DT2").Replace("\"", "") : string.Empty;
					this.SEEDDataTypes[2] = ( rm.GetString("DT3").Length > 0 ) ? rm.GetString("DT3").Replace("\"", "") : string.Empty;
					this.SEEDDataTypes[3] = ( rm.GetString("DT4").Length > 0 ) ? rm.GetString("DT4").Replace("\"", "") : string.Empty;
			
					return true;
				}

				return false;
			}
			catch (System.Resources.MissingManifestResourceException ex)
			{
				Monitor.sErrMsg(ex.Message);
				return false;
			}
			catch (System.IO.IOException ex)
			{
				Monitor.sErrMsg(ex.Message);
				return false;
			}
			catch (Exception ex)
			{
				Monitor.sErrMsg(ex.Message);
				return false;
			}
		}
		#endregion


	}
}
